﻿<template>
  <a-modal
    title="新增查询费用明细结果"
    :width="900"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleSubmit"
    @cancel="handleCancel">
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
        <a-form-item label="机构跟踪号 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入机构跟踪号 " v-decorator="['orgTraceNo']" />
        </a-form-item>
        <a-form-item label="单据流水号 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入单据流水号 " v-decorator="['docTraceNo']" />
        </a-form-item>
        <a-form-item label="院内门诊号/住院号 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入院内门诊号/住院号 " v-decorator="['iptOtpNo']" />
        </a-form-item>
        <a-form-item label="住院号“住院结算场景必传” " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入住院号“住院结算场景必传” " v-decorator="['iptNo']" />
        </a-form-item>
        <a-form-item label="患者费别00??? 自费 01??? 医保 返回空则使用查询账户信息时候的“费别” " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入患者费别00??? 自费 01??? 医保 返回空则使用查询账户信息时候的“费别” " v-decorator="['patientType']" />
        </a-form-item>
        <a-form-item label="就诊凭证类型 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入就诊凭证类型 " v-decorator="['mdtrtCertType']" />
        </a-form-item>
        <a-form-item label="就诊凭证编号 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入就诊凭证编号 " v-decorator="['mdtrtCertNo']" />
        </a-form-item>
        <a-form-item label="证件号 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入证件号 " v-decorator="['certNo']" />
        </a-form-item>
        <a-form-item label="姓名 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入姓名 " v-decorator="['psnName']" />
        </a-form-item>
        <a-form-item label="性别 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入性别 " v-decorator="['gend']" />
        </a-form-item>
        <a-form-item label="年龄 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入年龄 " v-decorator="['age']" />
        </a-form-item>
        <a-form-item label="门诊/住院流水号(医保门诊挂 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入门诊/住院流水号(医保门诊挂 " v-decorator="['mdtrtId']" />
        </a-form-item>
        <a-form-item label="医疗费总额 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入医疗费总额 " v-decorator="['medfeeSumamt']" />
        </a-form-item>
        <a-form-item label="人员编码“自费费别”的用户可以不传，但如果为“医保费别” 则必传 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入人员编码“自费费别”的用户可以不传，但如果为“医保费别” 则必传 " v-decorator="['psnNo']" />
        </a-form-item>
        <a-form-item label="险种类型“自费费别”的用户可以不传，但如果为“医保费别” 则必传 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入险种类型“自费费别”的用户可以不传，但如果为“医保费别” 则必传 " v-decorator="['insuType']" />
        </a-form-item>
        <a-form-item label="费用类型 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入费用类型 " v-decorator="['feeType']" />
        </a-form-item>
      </a-form>
    </a-spin>
  </a-modal>
</template>

<script>
  import {
    NitfOrg002aOutputAdd
  } from '@/api/modular/main/NitfOrg002aOutputManage'

  export default {
    data () {
      return {
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 15 }
        },
        visible: false,
        confirmLoading: false,
        form: this.$form.createForm(this)
      }
    },
    methods: {
      // 初始化方法
      add (record) {
        this.visible = true
      },
      /**
       * 提交表单
       */
      handleSubmit () {
        const { form: { validateFields } } = this
        this.confirmLoading = true
        validateFields((errors, values) => {
          if (!errors) {
            for (const key in values) {
              if (typeof (values[key]) === 'object') {
                values[key] = JSON.stringify(values[key])
              }
            }
            NitfOrg002aOutputAdd(values).then((res) => {
              if (res.success) {
                this.$message.success('新增成功')
                this.confirmLoading = false
                this.$emit('ok', values)
                this.handleCancel()
              } else {
                this.$message.error('新增失败：' + JSON.stringify(res.message))
              }
            }).finally((res) => {
              this.confirmLoading = false
            })
          } else {
            this.confirmLoading = false
          }
        })
      },
      handleCancel () {
        this.form.resetFields()
        this.visible = false
      }
    }
  }
</script>
